<p><?php echo $this -> Html -> link('Add a user', array('action' => 'add')); ?></p>
<p><?php echo $this -> Html -> link('Faculties', array('controller' => 'faculties', 'action' => 'index')); ?></p>

<table>
	<tr>
		<th>ID</th>
		<th>Name </th>
		<th>Surname</th>
		<th>E-mail</th>
		<th>Faculty</th>
		<th>Rights</th>
		<th style="text-align: center"> </th>
		<th style="text-align: center"> </th>
		<th style="text-align: center"> </th>
	</tr>

	<?php foreach ($users as $user): ?>

	<tr <?php echo ($user['User']['is_deleted'] ?  "style='backgroud-color: red'" : '')?>>
		<td><?php echo $this->Html->link($user['User']['id_user'],
			array('controller' => 'users', 'action' => 'profile', $user['User']['id_user'])); ?></td>
		<td><?php echo $user['User']['name']; ?></td>
		<td><?php echo $user['User']['surname']; ?></td>
		<td><?php echo $user['User']['email']; ?></td>
		<td><?php echo $user['Faculty']['faculty_name']; ?></td>
		<td><?php echo $user['User']['rights']; ?></td>
		<td style="text-align: center">
			<?php echo $this -> Html -> image('admin/view.gif', array('alt' => 'View', 'class' => 'flip', 'name' => $user['User']['id_user'])); ?>
		</td>
		<td style="text-align: center"><?php echo $this -> Html -> link($this -> Html -> image("admin/edit.png", array("alt" => "edit")), array('action' => 'edit', $user['User']['id_user']), array('escape' => false)); ?></td>
		<td style="text-align: center"><?php echo $this -> Form -> postLink($this -> Html -> image("admin/delete.gif", array("alt" => "delete")), array('action' => 'delete', $user['User']['id_user']), array('escape' => false, 'confirm' => 'Are you sure?')); ?></td>
	</tr>
	<tr>
		<td colspan="8">
		<div class="details" id="<?php echo $user['User']['id_user']; ?>">
			Birthday: <?php echo $user['User']['birthday']; ?><br />
			Birth place: <?php echo $user['User']['birth_place']; ?><br />
			ID card: <?php echo $user['User']['card_id']; ?><br />
			Photo set: 
			<?php
				if ($user['User']['photo'] == '') {
					echo 'no';
				} else {
					echo 'yes';
				}
			?>
			<br><br>
			User created: <?php echo $user['User']['created']; ?><br />
			<br />
			Gmail: <?php echo $user['User']['g_email']; ?><br />
			Dropbox: <?php echo $user['User']['d_email']; ?><br />
						
			<br />
			Goups created: <?php echo $user['User']['no_groups']; ?><br />
			Files shared: <?php echo $user['User']['no_files']; ?><br />
			Messages sent: <?php echo $user['User']['no_chat_messages']; ?><br />
			<br />
			<?php echo $this -> Html -> link("Reset password", array('action' => 'reset_password', $user['User']['id_user']), array('escape' => false, 'confirm' => 'Do you really want to reset the password?')); ?>
		</div></td>
	</tr>
	<?php endforeach; ?>
</table>
